package com.minghan.mhoauth.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.minghan.mhoauth.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.websocket.server.PathParam;

@RestController
public class LoginController {

    @Autowired
    UserDao userDao;
    @Autowired
    RedisTemplate redisTemplate;

    @GetMapping("/test")
    public String test(){
        redisTemplate.opsForValue().set("testKey","testVal");

        Object testVal = redisTemplate.opsForValue().get("testKey");
        return String.format(" mysql=%s \n redis=%s",
                userDao.selectList(Wrappers.lambdaQuery()).toString(),
                testVal);
    }

    //回调
    @RequestMapping("callback")
    public String c(@PathParam("code") String code){
        return "code:"+code;
    }
}
